/**
 * Copyright (C) 2006 ChangSha Sino-Town Science & Technology CO,.LTD. All rights reserved.
 * Sino-Town PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

package wzw.beans;

import java.util.HashMap;


/**
 * <p>代码和名称的组合对象，用于JComboBox,JTree等对象中。</p>
 * @author	WUZEWEN on 2006-3-10
 * @version	1.0
 * @see		Object#equals(java.lang.Object)
 * @see		Object#hashCode()
 * @see		HashMap
 * @since	JDK1.4
 */

public class CodeNameBean implements CodeNameEntity,Comparable<Object>{
	String code=null;		//代码
	String name=null;		//名称
	int orderNumber=0;		//排序的列,保持加入最开始加入时的顺序
	boolean boolFlag1 ;		//预留bool参数1
	int intValue1 ;		//预留int参数1
	int longValue1 ;		//预留long参数1
	
	public boolean isBoolFlag1() {
		return boolFlag1;
	}

	public void setBoolFlag1(boolean boolFlag1) {
		this.boolFlag1 = boolFlag1;
	}

	public int getIntValue1() {
		return intValue1;
	}

	public void setIntValue1(int intValue1) {
		this.intValue1 = intValue1;
	}

	public int getLongValue1() {
		return longValue1;
	}

	public void setLongValue1(int longValue1) {
		this.longValue1 = longValue1;
	}

	/**
	 * 
	 * @param dm 代码
	 * @param mc 名称
	 */
	public CodeNameBean(String dm,String mc){
		this(dm, mc, 0);
	}

	/**
	 * 
	 * @param dm 代码
	 * @param mc 名称
	 * @param orderNumber 排序id
	 */
	public CodeNameBean(String dm,String mc,int orderNumber){
		this.code=dm;
		this.name=mc;
		this.orderNumber=orderNumber;
	}
	
	/**
	 * 
	 * @param dm 代码
	 * @param mc 名称
	 * @param orderNumber 排序id
	 */
	public CodeNameBean(String dm,String mc,boolean boolFlag1){
		this.code=dm;
		this.name=mc;
		this.boolFlag1 = boolFlag1;
	}
	
	/**
	 * return when display.
	 */
	public String toString(){
		return name;
	}
	
	/**
	 * 定义两个对象是否相等。
	 * @param codeName 比较对象
	 */
	public boolean equals(Object codeName){

		if(codeName instanceof CodeNameBean){
			return (this.code.equals( ((CodeNameBean)codeName).getCode()) && 
					this.name.equals( ((CodeNameBean)codeName).getName()) );
		}else{
			return false;	
		}
	}

	/**
	 * 比较大小，注意，小的排在前面，所以是反向相减
	 * @param obj 比较对象
	 */
	public int compareTo(Object obj) {
		if(obj instanceof CodeNameBean ){
			return ((CodeNameBean)obj).orderNumber-this.orderNumber;
		}
		return -1;
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
	
	}
	
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}

}
